package com.platform.api.bzproject.controller;

import com.baomidou.mybatisplus.core.conditions.query.QueryWrapper;
import com.platform.api.bzproject.model.BzBaseInfo;
import com.platform.api.bzproject.service.BzBaseInfoService;
import com.platform.common.core.Result;
import io.swagger.annotations.Api;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import java.util.HashMap;
import java.util.Map;

/**
 * @author guoyunfei on 2021/8/12 14:08
 * @className BzBaseInfoController
 * @description TODO
 * @Version 1.0
 * 源码联系微信：2549789059
 */
@Api(tags = "壁纸分类")
@RestController
@RequestMapping("{appid}/baseInfo")
public class BzBaseInfoController {

    @Autowired
    private BzBaseInfoService bzBaseInfoService;

    @GetMapping("getBaseInfo")
    public Result getBaseInfo(@PathVariable String appid){

        BzBaseInfo baseInfo = bzBaseInfoService.getOne(new QueryWrapper<BzBaseInfo>().eq("appid", appid).last("limit 1"));

        return Result.success(baseInfo);
    }

    @GetMapping("getTaxrate")
    public Result getTaxrate(@PathVariable String appid){

        BzBaseInfo baseInfo = bzBaseInfoService.getOne(new QueryWrapper<BzBaseInfo>().eq("appid", appid).last("limit 1"));

        Map<String,Object> map = new HashMap<>(6);
        map.put("w_fee",baseInfo.getTaxrate().add(baseInfo.getPlatformRate()));
        map.put("lowestMoney",baseInfo.getLowestMoney());

        map.put("taxrate",baseInfo.getTaxrate());
        map.put("platformRate",baseInfo.getPlatformRate());
        return Result.success(map);
    }


}
